package com.gzist.elderlyserviceplatform.controller.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzist.elderlyserviceplatform.common.Result;
import com.gzist.elderlyserviceplatform.common.base.BaseDTO;
import com.gzist.elderlyserviceplatform.entity.po.Activity;
import com.gzist.elderlyserviceplatform.entity.vo.ActivityListByLatestVO;
import com.gzist.elderlyserviceplatform.entity.vo.InfoNewsQueryByLatestOrHotVO;
import com.gzist.elderlyserviceplatform.service.ActivityService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公益活动表
 */
@RestController
@Tag(name = "公益活动管理")
@RequestMapping("/api/client/activity")
@RequiredArgsConstructor
public class ActivityControllerC {

    private final ActivityService activityService;

    @GetMapping("/latestList")
    @Operation(summary = "首页公益活动列表", description = "只查询最新的四条")
    public Result<List<ActivityListByLatestVO>> listActivityLatest() {
        return Result.success(activityService.listActivityLatest(), "查询成功");
    }

    @PostMapping("/list")
    @Operation(summary = "查询公益活动列表", description = "查询公益活动列表")
    public Result<Page<Activity>> listActivity(
            @RequestBody
            @Parameter(description = "分页参数") BaseDTO baseDTO
    ) {
        return Result.success(activityService.listActivity(baseDTO), "查询成功");
    }

    @GetMapping("/detail/{id}")
    @Operation(summary = "查询单个公益活动详情", description = "查询公益活动详情")
    public Result<Activity> query(
            @PathVariable
            @Parameter(description = "公益活动id") String id
    ) {
        return Result.success(activityService.getById(id), "查询成功");
    }
}